i/** 
 *  @file       lattice.c
 *  @brief      点阵驱动程序
 *  @author     Z B T   
 *  @version    V0.1
 *  @date       2015-10
 */
 
#include "lattice.h"
#include "74HC595.h"
#include "delay.h"
#include "config.h"

unsigned char code tab0[] = 
{0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08,
 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80,
 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00,
 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00}; 

/**< 10字模 */
unsigned char code tab1[] = 
{0, 0, 0, 0, 0, 0, 8, 24, 14, 36, 8, 66, 8, 66, 8, 66, 
 8, 66, 8, 66, 8, 66, 8, 36, 62, 24, 0, 0, 0, 0, 0, 0};

/**< 09字模 */
unsigned char code tab2[] = 
{0, 0, 0, 0, 0, 0, 24, 24, 36, 36, 66, 66, 66, 66, 66,66, 
66, 100, 66, 88, 66, 64, 66, 64, 36, 36, 24, 28, 0, 0, 0, 0} ;

/**< 08字模 */
unsigned char code tab3[] = 
{0, 0, 0, 0, 0, 0, 24, 60, 36, 66, 66, 66, 66, 66, 66, 36,
66, 24, 66, 36, 66, 66, 66, 66, 36, 66, 24, 60, 0, 0, 0, 0};

/**< 07字模 */
unsigned char code tab4[] = 
{0, 0, 0, 0, 0, 0, 24, 126, 36, 34, 66, 34, 66, 16, 66, 16,
 66, 8, 66, 8, 66, 8, 66, 8, 36, 8, 24, 8, 0, 0, 0, 0};

/**< 06字模 */
unsigned char code tab5[] = 
{0, 0, 0, 0, 0, 0, 24, 56, 36, 36, 66, 2, 66, 2, 66, 26, 66,
 38, 66, 66, 66, 66, 66, 66, 36, 36, 24, 24, 0, 0, 0, 0};

/**< 05字模 */
unsigned char code tab6[] = 
{0, 0, 0, 0, 0, 0, 24, 126, 36, 2, 66, 2, 66, 2, 66, 26, 66,
 38, 66, 64, 66, 64, 66, 66, 36, 34, 24, 28, 0, 0, 0, 0};

/**< 04字模 */
unsigned char code tab7[] = 
{0, 0, 0, 0, 0, 0, 24, 32, 36, 48, 66, 40, 66, 36, 66, 36, 66,
34, 66, 34, 66, 126, 66, 32, 36, 32, 24, 120, 0, 0, 0, 0};

/**< 03字模 */
unsigned char code tab8[] = 
{0, 0, 0, 0, 0, 0, 24, 60, 36, 66, 66, 66, 66, 32, 66, 24, 66,
 32, 66, 64, 66, 64, 66, 66, 36, 34, 24, 28, 0, 0, 0, 0};

/**< 02字模 */
unsigned char code tab9[] = 
{0, 0, 0, 0, 0, 0, 24, 60, 36, 66, 66, 66, 66, 66, 66, 32, 66,
 32, 66, 16, 66, 8, 66, 4, 36, 66, 24, 126, 0, 0, 0, 0};

/**< 01字模 */
unsigned char code tab10[] = 
{0, 0, 0, 0, 0, 0, 24, 8, 36, 14, 66, 8, 66, 8, 66, 8, 66, 8, 66,
8, 66, 8, 66, 8, 36, 8, 24, 62, 0, 0, 0, 0};

/**< 00字模 */
unsigned char code tab11[] = 
{0, 0, 0, 0, 0, 0, 24, 24, 36, 36, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 36, 36, 24, 24, 0, 0, 0, 0};

/**<  GO  */
unsigned char code tab12[] = 
{0, 0, 0, 0, 0, 0, 60, 28, 34, 34, 34, 65, 1, 65, 1, 65, 1, 65, 113,
 65, 33, 65, 34, 65, 34, 34, 28, 28, 0, 0, 0, 0};

/**
 *  点阵显示倒计时
 *  @param None
 *  @return None
 */
void count_down(void)
{
    unsigned char i;
    unsigned char row_value;
    
    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab1[2 * i + 1], tab1[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab2[2 * i + 1], tab2[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab4[2 * i + 1], tab4[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab1[2 * i + 1], tab1[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab4[2 * i + 1], tab4[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab5[2 * i + 1], tab5[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab6[2 * i + 1], tab6[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab7[2 * i + 1], tab7[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab8[2 * i + 1], tab8[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab9[2 * i + 1], tab9[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab10[2 * i + 1], tab10[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab11[2 * i + 1], tab11[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);

    for (i = 0; i < 16; i++)
    {
        hc595_send_4bit_data(~tab12[2 * i + 1], tab12[2 * i], tab0[2 * i], tab0[2 * i + 1]);
    }
    delay_ms(200);
    /**< clear screen */
    hc595_send_4bit_data(0xff, 0xff, 0x00, 0x00);
}